<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('vote',function(Blueprint $table) {

            $table->charset = 'utf8mb4';

            $table->collation = 'utf8mb4_unicode_ci';

            // 数据类型
            $table->engine = 'InnoDB';

            $table->comment('投票表');

            // id
            $table->bigIncrements('id');
            $table->uuid('vote_id')->unique()->nullable(false);
            $table->string('admin_id')->nullable(false)->comment('创建者');
            $table->string('c_key',85)->nullable(false);
            $table->text('t_key')->nullable()->comment('标签');
            $table->text('slug')->nullable()->comment('翻译URL标题，友好的SEO链接');
            $table->string('title',255)->unique()->nullable(false);
            $table->string('time_on',85)->nullable()->comment('开始时间');
            $table->string('time_off',85)->nullable()->comment('结束时间');
            $table->integer('sort_id')->unsigned()->default(0)->comment('排序');
            $table->text('vote_rule')->nullable(false)->comment('问卷规则');
            $table->text('prize')->nullable(false)->comment('问卷奖品');
            $table->string('keywords',125)->nullable()->comment('关键词');
            $table->string('address',125)->nullable()->comment('地址');
            $table->string('tel_phone',55)->nullable()->comment('联系电话');
            $table->string('sponsor',85)->nullable()->comment('主办方或者赞助商');
            $table->string('wx_qr_uri',125)->nullable()->comment('微信二维码链接');
            $table->string('qr_code',125)->nullable()->comment('二维码');
            $table->integer('accumulate_votes')->unsigned()->default(0)->comment('累计票数');
            $table->integer('player_num')->unsigned()->nullable()->default(2)->comment('参与选手人数');
            $table->longText('content')->nullable()->comment('活动内容');
            $table->text('introduction')->nullable()->comment('活动简介');
            $table->longText('images')->nullable()->comment('图片集合');
            $table->string('thumbnail',255)->nullable();
            $table->smallInteger('grade')->nullable()->unsigned()->default(1)->comment('评分');
            $table->smallInteger('is_using')->nullable()->unsigned()->default(1)->comment('状态');
            $table->smallInteger('is_comments')->nullable()->unsigned()->default(1)->comment('评论');
            $table->timestamps();

            $table->index('vote_id');
            $table->index('admin_id');
            $table->index('title');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('vote');
    }
};
